<template>
  <div>
    <h1 :style="{opacity}">React太难了</h1>
    <button @click="bailan">不学了</button>
  </div>
</template>

<script>
export default {
  name:"App",
  data(){
    return{
      opacity:0.5,
      timerId:null,
    }
  },
  methods:{
    bailan(){
      this.$destroy();
    }
  },
  mounted(){
    this.timerId = setInterval(()=>{
      console.log(Math.random());
      this.opacity-=0.05;
      if(this.opacity<=0){
        this.opacity=1;
      }
    },10)
  },
  beforeDestroy(){
    clearInterval(this.timerId);
  }
}
</script>
